<!DOCTYPE HTML>
<html lang="zh-tw" >
    <!-- Start book python高级 -->
    <head>
        <!-- head:start -->
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>索引 | python高级</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-splitter/splitter.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-emphasize/plugin.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../day17/04.user.html" />
    
    
    <link rel="prev" href="../day17/02.transaction.html" />
    

        <!-- head:end -->
    </head>
    <body>
        <!-- body:start -->
        
    <div class="book"
        data-level="7.3"
        data-chapter-title="索引"
        data-filepath="day17/03.sql_index.md"
        data-basepath=".."
        data-revision="Wed Sep 26 2018 22:46:13 GMT+0800 (CST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Python高级
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="day11/00.readme.html">
            
                
                    <a href="../day11/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        Python语法高级专题1
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="day11/01.GIL.html">
            
                
                    <a href="../day11/01.GIL.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        GIL问题
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="day11/02.copy.html">
            
                
                    <a href="../day11/02.copy.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        赋值-浅拷贝-深拷贝
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="day11/03.import.html">
            
                
                    <a href="../day11/03.import.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        import导入模块
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="day11/04.review.html">
            
                
                    <a href="../day11/04.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="day12/00.readme.html">
            
                
                    <a href="../day12/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        Python语法高级专题2
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="day12/01.mro.html">
            
                
                    <a href="../day12/01.mro.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        多继承和MRO顺序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="day12/02.property.html">
            
                
                    <a href="../day12/02.property.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        property属性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="day12/03.magic.html">
            
                
                    <a href="../day12/03.magic.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        魔法属性和方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="day12/04.with.html">
            
                
                    <a href="../day12/04.with.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        with管理上下文
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="day12/05.review.html">
            
                
                    <a href="../day12/05.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="day13/00.readme.html">
            
                
                    <a href="../day13/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        Python语法之装饰器
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="day13/01.closure.html">
            
                
                    <a href="../day13/01.closure.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        闭包
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="day13/02.decorator.html">
            
                
                    <a href="../day13/02.decorator.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        装饰器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="day13/03.review.html">
            
                
                    <a href="../day13/03.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="day14/00.readme.html">
            
                
                    <a href="../day14/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        MySQL数据库基本操作
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="day14/01.数据库概述.html">
            
                
                    <a href="../day14/01.数据库概述.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        数据库概述
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="day14/02.数据类型和约束.html">
            
                
                    <a href="../day14/02.数据类型和约束.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        数据完整性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="day14/03.Navicat.html">
            
                
                    <a href="../day14/03.Navicat.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        图形化客户端Navicat
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="day14/04.命令行客户端.html">
            
                
                    <a href="../day14/04.命令行客户端.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        命令行客户端SQL的使用
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.4.1" data-path="day14/05.sql_con.html">
            
                
                    <a href="../day14/05.sql_con.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.1.</b>
                        
                        登录和退出数据库
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.2" data-path="day14/07.sql_table_struct.html">
            
                
                    <a href="../day14/07.sql_table_struct.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.2.</b>
                        
                        表结构的操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.3" data-path="day14/06.sql_database.html">
            
                
                    <a href="../day14/06.sql_database.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.3.</b>
                        
                        数据库的操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.4" data-path="day14/08.表数据操作.html">
            
                
                    <a href="../day14/08.表数据操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.4.</b>
                        
                        表数据的操作
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="day14/09.review.html">
            
                
                    <a href="../day14/09.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        知识总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="day15/00.readme.html">
            
                
                    <a href="../day15/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        MYSQL数据库进阶操作
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="day15/01.练习.html">
            
                
                    <a href="../day15/01.练习.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        练习强化
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="day15/02.where条件.html">
            
                
                    <a href="../day15/02.where条件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        条件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="day15/03.排序查询.html">
            
                
                    <a href="../day15/03.排序查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        排序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="day15/04.分页查询.html">
            
                
                    <a href="../day15/04.分页查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        分页
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="day15/05.聚合函数.html">
            
                
                    <a href="../day15/05.聚合函数.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        聚合函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="day15/06.分组.html">
            
                
                    <a href="../day15/06.分组.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.6.</b>
                        
                        分组
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="day15/07.连接.html">
            
                
                    <a href="../day15/07.连接.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.7.</b>
                        
                        连接
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="day15/08.自连接.html">
            
                
                    <a href="../day15/08.自连接.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.</b>
                        
                        自连接
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.9" data-path="day15/09.子查询.html">
            
                
                    <a href="../day15/09.子查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.9.</b>
                        
                        子查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.10" data-path="day15/10.总结.html">
            
                
                    <a href="../day15/10.总结.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.10.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="day16/readme.html">
            
                
                    <a href="../day16/readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        MYSQL数据库编程
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="day16/data.html">
            
                
                    <a href="../day16/data.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        数据准备
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="day16/sql_code.html">
            
                
                    <a href="../day16/sql_code.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        SQL演练
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="day16/dbdesign.html">
            
                
                    <a href="../day16/dbdesign.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        数据库设计
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="day16/pymysql.html">
            
                
                    <a href="../day16/pymysql.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        数据库编程
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="day16/zongjie.html">
            
                
                    <a href="../day16/zongjie.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" data-path="day17/00.readme.html">
            
                
                    <a href="../day17/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        MySQL数据库高级用法
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.1" data-path="day17/01.view.html">
            
                
                    <a href="../day17/01.view.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.1.</b>
                        
                        视图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="day17/02.transaction.html">
            
                
                    <a href="../day17/02.transaction.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.2.</b>
                        
                        事务
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="7.3" data-path="day17/03.sql_index.html">
            
                
                    <a href="../day17/03.sql_index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.3.</b>
                        
                        索引
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4" data-path="day17/04.user.html">
            
                
                    <a href="../day17/04.user.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.</b>
                        
                        用户管理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.5" data-path="day17/05.master_slave.html">
            
                
                    <a href="../day17/05.master_slave.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.</b>
                        
                        主从配置
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.6" data-path="day17/06.review.html">
            
                
                    <a href="../day17/06.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.6.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="8" data-path="day18/00.readme.html">
            
                
                    <a href="../day18/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        miniweb框架
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="8.1" data-path="day18/01.框架是什么.html">
            
                
                    <a href="../day18/01.框架是什么.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.1.</b>
                        
                        框架概念
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="day18/02.实现框架.html">
            
                
                    <a href="../day18/02.实现框架.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.2.</b>
                        
                        实现一个简单的框架
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="day18/03.模板.html">
            
                
                    <a href="../day18/03.模板.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.3.</b>
                        
                        模板替换
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.4" data-path="day18/04.路由.html">
            
                
                    <a href="../day18/04.路由.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.4.</b>
                        
                        路由概念
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.5" data-path="day18/05.显示股票数据.html">
            
                
                    <a href="../day18/05.显示股票数据.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.5.</b>
                        
                        股票收藏夹
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.6" data-path="day18/05.review.html">
            
                
                    <a href="../day18/05.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.6.</b>
                        
                        复习
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    本書使用 GitBook 釋出
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >python高级</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="3-&#x7D22;&#x5F15;">3. &#x7D22;&#x5F15;</h1>
<h2 id="31-&#x5B66;&#x4E60;&#x76EE;&#x6807;">3.1 &#x5B66;&#x4E60;&#x76EE;&#x6807;</h2>
<ul>
<li>&#x80FD;&#x591F;&#x8BF4;&#x51FA;&#x7D22;&#x5F15;&#x7684;&#x4F5C;&#x7528;</li>
<li>&#x80FD;&#x591F;&#x5199;&#x51FA;&#x521B;&#x5EFA;&#x7D22;&#x5F15;&#x7684; SQL &#x8BED;&#x53E5;</li>
<li>&#x80FD;&#x591F;&#x5199;&#x51FA;&#x67E5;&#x770B;&#x7D22;&#x5F15;&#x7684; SQL &#x8BED;&#x53E5;</li>
<li>&#x80FD;&#x591F;&#x5199;&#x51FA;&#x5220;&#x9664;&#x7D22;&#x5F15;&#x7684; SQL &#x8BED;&#x53E5;</li>
</ul>
<hr>
<h2 id="31-&#x4E3A;&#x4EC0;&#x4E48;&#x9700;&#x8981;&#x7D22;&#x5F15;">3.1 &#x4E3A;&#x4EC0;&#x4E48;&#x9700;&#x8981;&#x7D22;&#x5F15;</h2>
<blockquote>
<p>&#x601D;&#x8003;: &#x5982;&#x4F55;&#x5728;&#x4E00;&#x4E2A;&#x56FE;&#x4E66;&#x9986;&#x4E2D;&#x627E;&#x5230;&#x4E00;&#x672C;&#x4E66;&#x7684;
    &#x5728;&#x56FE;&#x4E66;&#x9986;&#x4E2D;&#x5982;&#x679C;&#x5176;&#x4ED6;&#x8F85;&#x52A9;&#x624B;&#x6BB5;&#x53EA;&#x80FD;&#x4E00;&#x6761;&#x9053;&#x8D70;&#x5230;&#x9ED1;&#xFF0C;&#x4E00;&#x672C;&#x4E66;-&gt;&#x4E00;&#x672C;&#x4E66;&#x7684;&#x626B;&#xFF0C;&#x7EC8;&#x4E8E;&#x7ECF;&#x8FC7;1&#x4E2A;&#x5C0F;&#x65F6;&#x7684;&#x8FDE;&#x7EED;&#x626B;&#x63CF;&#x53D1;&#x73B0;&#x4F60;&#x9700;&#x8981;&#x770B;&#x7684;&#x90A3;&#x672C;&#x4E66;&#x5728;&#x4E00;&#x5206;&#x949F;&#x4E4B;&#x524D;&#x88AB;&#x4EBA;&#x501F;&#x8D70;&#x4E86;&#x3002;&#x8FD9;&#x79CD;&#x5C31;&#x662F;&#x987A;&#x5E8F;&#x67E5;&#x627E;&#x3002;
    &#x56FE;&#x4E66;&#x9986;&#x7BA1;&#x7406;&#x5458;&#x53D1;&#x73B0;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#xFF0C;&#x4E8E;&#x662F;&#x51B3;&#x5B9A;&#x51CF;&#x5C11;&#x8FD9;&#x6837;&#x7684;(&#xFF1E;&#xFE4F;&#xFF1C;)&#x60B2;&#x5267;&#x6545;&#x4E8B;&#x3002;
    &#x4E3A;&#x540C;&#x5B66;&#x4EEC;&#x8D2D;&#x7F6E;&#x4E86;&#x4E00;&#x5957;&#x56FE;&#x4E66;&#x9986;&#x7BA1;&#x7406;&#x7CFB;&#x7EDF;&#xFF0C;&#x5927;&#x5BB6;&#x8981;&#x627E;&#x4E66;&#x7C4D;&#x5148;&#x5728;&#x7CFB;&#x7EDF;&#x4E0A;&#x67E5;&#x627E;&#x5230;&#x4E66;&#x7C4D;&#x6240;&#x5728;&#x7684;&#x623F;&#x5C4B;&#x7F16;&#x53F7;&#x548C;&#x8D27;&#x67B6;&#x7F16;&#x53F7;&#xFF0C;&#x7136;&#x540E;&#x5C31;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5927;&#x6447;&#x5927;&#x6446;&#x7684;&#x53BB;&#x53D6;&#x4E66;&#x4E86;&#x3002;&#x6211;&#x4EEC;&#x628A;&#x8FD9;&#x79CD;&#x80FD;&#x591F;&#x5E2E;&#x52A9;&#x6211;&#x4EEC;&#x5FEB;&#x901F;&#x67E5;&#x8BE2;&#x6570;&#x636E;&#x7684;&#x7EBF;&#x7D22;&#x5C31;&#x79F0;&#x4E4B;&#x4E3A;&#x7D22;&#x5F15;&#x3002;</p>
</blockquote>
<p>&#x4E00;&#x822C;&#x7684;&#x5E94;&#x7528;&#x7CFB;&#x7EDF;&#x5BF9;&#x6BD4;&#x6570;&#x636E;&#x5E93;&#x7684;&#x8BFB;&#x5199;&#x6BD4;&#x4F8B;&#x5728;10:1&#x5DE6;&#x53F3;(&#x5373;&#x6709;10&#x6B21;&#x67E5;&#x8BE2;&#x64CD;&#x4F5C;&#x65F6;&#x6709;1&#x6B21;&#x5199;&#x7684;&#x64CD;&#x4F5C;)&#xFF0C;</p>
<p>&#x800C;&#x4E14;&#x63D2;&#x5165;&#x64CD;&#x4F5C;&#x548C;&#x66F4;&#x65B0;&#x64CD;&#x4F5C;&#x5F88;&#x5C11;&#x51FA;&#x73B0;&#x6027;&#x80FD;&#x95EE;&#x9898;&#xFF0C;</p>
<p>&#x9047;&#x5230;&#x6700;&#x591A;&#x3001;&#x6700;&#x5BB9;&#x6613;&#x51FA;&#x95EE;&#x9898;&#x8FD8;&#x662F;&#x4E00;&#x4E9B;&#x590D;&#x6742;&#x7684;&#x67E5;&#x8BE2;&#x64CD;&#x4F5C;&#xFF0C;&#x6240;&#x4EE5;&#x67E5;&#x8BE2;&#x8BED;&#x53E5;&#x7684;&#x4F18;&#x5316;&#x663E;&#x7136;&#x662F;&#x91CD;&#x4E2D;&#x4E4B;&#x91CD;&#x3002;&#x5F53;&#x6570;&#x636E;&#x5E93;&#x4E2D;&#x6570;&#x636E;&#x91CF;&#x5F88;&#x5927;&#x65F6;&#xFF0C;&#x67E5;&#x627E;&#x6570;&#x636E;&#x4F1A;&#x53D8;&#x5F97;&#x5F88;&#x6162;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x7D22;&#x5F15;&#x6765;&#x63D0;&#x9AD8;&#x6570;&#x636E;&#x5E93;&#x7684;&#x67E5;&#x8BE2;&#x6548;&#x7387;&#x3002;</p>
<blockquote>
<p>&#x7D22;&#x5F15;&#x662F;&#x4EC0;&#x4E48;</p>
</blockquote>
<p>&#x7D22;&#x5F15;&#x662F;&#x4E00;&#x79CD;&#x7279;&#x6B8A;&#x7684;&#x6587;&#x4EF6;(InnoDB&#x6570;&#x636E;&#x8868;&#x4E0A;&#x7684;&#x7D22;&#x5F15;&#x662F;&#x8868;&#x7A7A;&#x95F4;&#x7684;&#x4E00;&#x4E2A;&#x7EC4;&#x6210;&#x90E8;&#x5206;)&#xFF0C;&#x5B83;&#x4EEC;&#x5305;&#x542B;&#x7740;&#x5BF9;&#x6570;&#x636E;&#x8868;&#x91CC;&#x6240;&#x6709;&#x8BB0;&#x5F55;&#x7684;&#x4F4D;&#x7F6E;&#x4FE1;&#x606F;&#x3002;</p>
<p>&#x66F4;&#x901A;&#x4FD7;&#x7684;&#x8BF4;&#xFF0C;&#x6570;&#x636E;&#x5E93;&#x7D22;&#x5F15;&#x597D;&#x6BD4;&#x662F;&#x4E00;&#x672C;&#x4E66;&#x524D;&#x9762;&#x7684;&#x76EE;&#x5F55;&#xFF0C;&#x80FD;&#x52A0;&#x5FEB;&#x6570;&#x636E;&#x5E93;&#x7684;&#x67E5;&#x8BE2;&#x901F;&#x5EA6;.</p>
<h3 id="32-&#x7D22;&#x5F15;&#x539F;&#x7406;">3.2 &#x7D22;&#x5F15;&#x539F;&#x7406;</h3>
<p>&#x9664;&#x4E86;&#x8BCD;&#x5178;&#xFF0C;&#x751F;&#x6D3B;&#x4E2D;&#x968F;&#x5904;&#x53EF;&#x89C1;&#x7D22;&#x5F15;&#x7684;&#x4F8B;&#x5B50;&#xFF0C;&#x5982;&#x706B;&#x8F66;&#x7AD9;&#x7684;&#x8F66;&#x6B21;&#x8868;&#x3001;&#x56FE;&#x4E66;&#x7684;&#x76EE;&#x5F55;&#x7B49;&#x3002;&#x5B83;&#x4EEC;&#x7684;&#x539F;&#x7406;&#x90FD;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x901A;&#x8FC7;&#x4E0D;&#x65AD;&#x7684;&#x7F29;&#x5C0F;&#x60F3;&#x8981;&#x83B7;&#x5F97;&#x6570;&#x636E;&#x7684;&#x8303;&#x56F4;&#x6765;&#x7B5B;&#x9009;&#x51FA;&#x6700;&#x7EC8;&#x60F3;&#x8981;&#x7684;&#x7ED3;&#x679C;&#xFF0C;&#x540C;&#x65F6;&#x628A;&#x968F;&#x673A;&#x7684;&#x4E8B;&#x4EF6;&#x53D8;&#x6210;&#x987A;&#x5E8F;&#x7684;&#x4E8B;&#x4EF6;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x6211;&#x4EEC;&#x603B;&#x662F;&#x901A;&#x8FC7;&#x540C;&#x4E00;&#x79CD;&#x67E5;&#x627E;&#x65B9;&#x5F0F;&#x6765;&#x9501;&#x5B9A;&#x6570;&#x636E;&#x3002;</p>
<p>&#x6570;&#x636E;&#x5E93;&#x4E5F;&#x662F;&#x4E00;&#x6837;&#xFF0C;&#x4F46;&#x663E;&#x7136;&#x8981;&#x590D;&#x6742;&#x8BB8;&#x591A;&#xFF0C;&#x56E0;&#x4E3A;&#x4E0D;&#x4EC5;&#x9762;&#x4E34;&#x7740;&#x7B49;&#x503C;&#x67E5;&#x8BE2;&#xFF0C;&#x8FD8;&#x6709;&#x8303;&#x56F4;&#x67E5;&#x8BE2;(&gt;&#x3001;&lt;&#x3001;between&#x3001;in)&#x3001;&#x6A21;&#x7CCA;&#x67E5;&#x8BE2;(like)&#x3001;&#x5E76;&#x96C6;&#x67E5;&#x8BE2;(or)&#x7B49;&#x7B49;&#x3002;&#x6570;&#x636E;&#x5E93;&#x5E94;&#x8BE5;&#x9009;&#x62E9;&#x600E;&#x4E48;&#x6837;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x5E94;&#x5BF9;&#x6240;&#x6709;&#x7684;&#x95EE;&#x9898;&#x5462;&#xFF1F;&#x6211;&#x4EEC;&#x56DE;&#x60F3;&#x5B57;&#x5178;&#x7684;&#x4F8B;&#x5B50;&#xFF0C;&#x80FD;&#x4E0D;&#x80FD;&#x628A;&#x6570;&#x636E;&#x5206;&#x6210;&#x6BB5;&#xFF0C;&#x7136;&#x540E;&#x5206;&#x6BB5;&#x67E5;&#x8BE2;&#x5462;&#xFF1F;&#x6700;&#x7B80;&#x5355;&#x7684;&#x5982;&#x679C;1000&#x6761;&#x6570;&#x636E;&#xFF0C;1&#x5230;100&#x5206;&#x6210;&#x7B2C;&#x4E00;&#x6BB5;&#xFF0C;101&#x5230;200&#x5206;&#x6210;&#x7B2C;&#x4E8C;&#x6BB5;&#xFF0C;201&#x5230;300&#x5206;&#x6210;&#x7B2C;&#x4E09;&#x6BB5;&#x2026;&#x2026;&#x8FD9;&#x6837;&#x67E5;&#x7B2C;250&#x6761;&#x6570;&#x636E;&#xFF0C;&#x53EA;&#x8981;&#x627E;&#x7B2C;&#x4E09;&#x6BB5;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#xFF0C;&#x4E00;&#x4E0B;&#x5B50;&#x53BB;&#x9664;&#x4E86;90%&#x7684;&#x65E0;&#x6548;&#x6570;&#x636E;&#x3002;</p>
<p><img src="../assets/day17/&#x7D22;&#x5F15;&#x539F;&#x7406;&#x56FE;.jpg" alt=""></p>
<h3 id="33-&#x7D22;&#x5F15;&#x7684;&#x4F7F;&#x7528;">3.3 &#x7D22;&#x5F15;&#x7684;&#x4F7F;&#x7528;</h3>
<ul>
<li>&#x67E5;&#x770B;&#x8868;&#x4E2D;&#x5DF2;&#x6709;&#x7D22;&#x5F15;</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">show</span> <span class="hljs-keyword">index</span> <span class="hljs-keyword">from</span> &#x8868;&#x540D;;</span>
</code></pre>
<ul>
<li>&#x521B;&#x5EFA;&#x7D22;&#x5F15;<ul>
<li>&#x5982;&#x679C;&#x6307;&#x5B9A;&#x5B57;&#x6BB5;&#x662F;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x9700;&#x8981;&#x6307;&#x5B9A;&#x957F;&#x5EA6;&#xFF0C;&#x5EFA;&#x8BAE;&#x957F;&#x5EA6;&#x4E0E;&#x5B9A;&#x4E49;&#x5B57;&#x6BB5;&#x65F6;&#x7684;&#x957F;&#x5EA6;&#x4E00;&#x81F4;</li>
<li>&#x5B57;&#x6BB5;&#x7C7B;&#x578B;&#x5982;&#x679C;&#x4E0D;&#x662F;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x53EF;&#x4EE5;&#x4E0D;&#x586B;&#x5199;&#x957F;&#x5EA6;&#x90E8;&#x5206;</li>
</ul>
</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">create</span> <span class="hljs-keyword">index</span> &#x7D22;&#x5F15;&#x540D;&#x79F0; <span class="hljs-keyword">on</span> &#x8868;&#x540D;(&#x5B57;&#x6BB5;&#x540D;&#x79F0;(&#x957F;&#x5EA6;))
</span></code></pre>
<ul>
<li>&#x5220;&#x9664;&#x7D22;&#x5F15;&#xFF1A;</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">drop</span> <span class="hljs-keyword">index</span> &#x7D22;&#x5F15;&#x540D;&#x79F0; <span class="hljs-keyword">on</span> &#x8868;&#x540D;;</span>
</code></pre>
<h2 id="34-&#x9A8C;&#x8BC1;&#x7D22;&#x5F15;&#x662F;&#x5426;&#x80FD;&#x591F;&#x63D0;&#x5347;&#x67E5;&#x8BE2;&#x6027;&#x80FD;">3.4 &#x9A8C;&#x8BC1;&#x7D22;&#x5F15;&#x662F;&#x5426;&#x80FD;&#x591F;&#x63D0;&#x5347;&#x67E5;&#x8BE2;&#x6027;&#x80FD;</h2>
<h3 id="341-&#x521B;&#x5EFA;&#x6D4B;&#x8BD5;&#x8868;testindex">3.4.1 &#x521B;&#x5EFA;&#x6D4B;&#x8BD5;&#x8868;testindex</h3>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">create</span> <span class="hljs-keyword">table</span> test_index(title <span class="hljs-built_in">varchar</span>(<span class="hljs-number">10</span>));</span>
</code></pre>
<h3 id="342-&#x4F7F;&#x7528;python&#x7A0B;&#x5E8F;&#xFF08;ipython&#x4E5F;&#x53EF;&#x4EE5;&#xFF09;&#x901A;&#x8FC7;pymsql&#x6A21;&#x5757;-&#x5411;&#x8868;&#x4E2D;&#x52A0;&#x5165;&#x5341;&#x4E07;&#x6761;&#x6570;&#x636E;">3.4.2 &#x4F7F;&#x7528;python&#x7A0B;&#x5E8F;&#xFF08;ipython&#x4E5F;&#x53EF;&#x4EE5;&#xFF09;&#x901A;&#x8FC7;pymsql&#x6A21;&#x5757; &#x5411;&#x8868;&#x4E2D;&#x52A0;&#x5165;&#x5341;&#x4E07;&#x6761;&#x6570;&#x636E;</h3>
<p><strong>&#x6CE8;&#x610F;: &#x53EF;&#x80FD;&#x5F53;&#x524D;&#x7EC8;&#x7AEF;&#x5728;&#x524D;&#x9762;&#x9A8C;&#x8BC1;&#x4E8B;&#x52A1;&#x7684;&#x65F6;&#x5019;&#x5DF2;&#x7ECF;&#x5173;&#x95ED;&#x4E86;&#x81EA;&#x52A8;&#x63D0;&#x4EA4;&#x3002;
&#x56E0;&#x6B64;&#x6700;&#x7B80;&#x5355;&#x7684;&#x65B9;&#x5F0F;&#x5C31;&#x662F;&#x91CD;&#x5F00;mysql&#x7EC8;&#x7AEF;&#x3002;
</strong></p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> pymysql <span class="hljs-keyword">import</span> connect

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span><span class="hljs-params">()</span>:</span>
    <span class="hljs-comment"># &#x521B;&#x5EFA;Connection&#x8FDE;&#x63A5;</span>
    conn = connect(host=<span class="hljs-string">&apos;localhost&apos;</span>,port=<span class="hljs-number">3306</span>,database=<span class="hljs-string">&apos;jing_dong&apos;</span>,user=<span class="hljs-string">&apos;root&apos;</span>,password=<span class="hljs-string">&apos;mysql&apos;</span>,charset=<span class="hljs-string">&apos;utf8&apos;</span>)
    <span class="hljs-comment"># &#x83B7;&#x5F97;Cursor&#x5BF9;&#x8C61;</span>
    cursor = conn.cursor()
    <span class="hljs-comment"># &#x63D2;&#x5165;10&#x4E07;&#x6B21;&#x6570;&#x636E;</span>
    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">100000</span>):
        cursor.execute(<span class="hljs-string">&quot;insert into test_index values(&apos;ha-%d&apos;)&quot;</span> % i)
    <span class="hljs-comment"># &#x63D0;&#x4EA4;&#x6570;&#x636E;</span>
    conn.commit()

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">&quot;__main__&quot;</span>:
    main()
</code></pre>
<h4 id="343-&#x67E5;&#x8BE2;">3.4.3 &#x67E5;&#x8BE2;</h4>
<ul>
<li>&#x5F00;&#x542F;&#x8FD0;&#x884C;&#x65F6;&#x95F4;&#x76D1;&#x6D4B;&#xFF1A;</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">set</span> profiling=<span class="hljs-number">1</span>;</span>
</code></pre>
<ul>
<li>&#x67E5;&#x627E;&#x7B2C;1&#x4E07;&#x6761;&#x6570;&#x636E;ha-99999</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">select</span> * <span class="hljs-keyword">from</span> test_index <span class="hljs-keyword">where</span> title=<span class="hljs-string">&apos;ha-99999&apos;</span>;</span>
</code></pre>
<ul>
<li>&#x67E5;&#x770B;&#x6267;&#x884C;&#x7684;&#x65F6;&#x95F4;&#xFF1A;</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">show</span> <span class="hljs-keyword">profiles</span>;</span>
</code></pre>
<ul>
<li>&#x4E3A;&#x8868;title_index&#x7684;title&#x5217;&#x521B;&#x5EFA;&#x7D22;&#x5F15;&#xFF1A;</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">create</span> <span class="hljs-keyword">index</span> title_index <span class="hljs-keyword">on</span> test_index(title(<span class="hljs-number">10</span>));</span>
</code></pre>
<ul>
<li>&#x6267;&#x884C;&#x67E5;&#x8BE2;&#x8BED;&#x53E5;&#xFF1A;</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">select</span> * <span class="hljs-keyword">from</span> test_index <span class="hljs-keyword">where</span> title=<span class="hljs-string">&apos;ha-99999&apos;</span>;</span>
</code></pre>
<ul>
<li>&#x518D;&#x6B21;&#x67E5;&#x770B;&#x6267;&#x884C;&#x7684;&#x65F6;&#x95F4;</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">show</span> <span class="hljs-keyword">profiles</span>;</span>
</code></pre>
<h2 id="35-&#x603B;&#x7ED3;">3.5 &#x603B;&#x7ED3;</h2>
<ul>
<li>&#x7D22;&#x5F15;&#x53EF;&#x4EE5;&#x660E;&#x663E;&#x63D0;&#x9AD8;&#x67D0;&#x4E9B;&#x5B57;&#x6BB5;&#x7684;&#x67E5;&#x8BE2;&#x6548;&#x7387;</li>
<li>&#x7D22;&#x5F15;&#x4F7F;&#x7528; <ul>
<li>&#x521B;&#x5EFA; create index xxx on &#x8868;&#x540D;(&#x5B57;&#x6BB5;&#x540D;[(&#x7D22;&#x5F15;&#x957F;&#x5EA6; &#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;&#x624D;&#x9700;&#x8981;&#x6307;&#x5B9A;)])</li>
<li>&#x67E5;&#x770B; show index for xxx</li>
</ul>
</li>
</ul>
<ul>
<li>&#x7D22;&#x5F15;&#x7684;&#x526F;&#x4F5C;&#x7528;-&#x7D22;&#x5F15;&#x867D;&#x597D; &#x4E0D;&#x8981;&#x8D2A;&#x676F;<ul>
<li>&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;&#x5EFA;&#x7ACB;&#x592A;&#x591A;&#x7684;&#x7D22;&#x5F15;&#x5C06;&#x4F1A;&#x5F71;&#x54CD;&#x66F4;&#x65B0;&#x548C;&#x63D2;&#x5165;&#x7684;&#x901F;&#x5EA6;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x9700;&#x8981;&#x540C;&#x6837;&#x66F4;&#x65B0;&#x6BCF;&#x4E2A;&#x7D22;&#x5F15;&#x6587;&#x4EF6;&#x3002;&#x5BF9;&#x4E8E;&#x4E00;&#x4E2A;&#x7ECF;&#x5E38;&#x9700;&#x8981;&#x66F4;&#x65B0;&#x548C;&#x63D2;&#x5165;&#x7684;&#x8868;&#x683C;&#xFF0C;&#x5C31;&#x6CA1;&#x6709;&#x5FC5;&#x8981;&#x4E3A;&#x4E00;&#x4E2A;&#x5F88;&#x5C11;&#x4F7F;&#x7528;&#x7684;where&#x5B57;&#x53E5;&#x5355;&#x72EC;&#x5EFA;&#x7ACB;&#x7D22;&#x5F15;&#x4E86;&#xFF0C;&#x5BF9;&#x4E8E;&#x6BD4;&#x8F83;&#x5C0F;&#x7684;&#x8868;&#xFF0C;&#x6392;&#x5E8F;&#x7684;&#x5F00;&#x9500;&#x4E0D;&#x4F1A;&#x5F88;&#x5927;&#xFF0C;&#x4E5F;&#x6CA1;&#x6709;&#x5FC5;&#x8981;&#x5EFA;&#x7ACB;&#x53E6;&#x5916;&#x7684;&#x7D22;&#x5F15;&#x3002;</li>
<li>&#x5EFA;&#x7ACB;&#x7D22;&#x5F15;&#x4F1A;&#x5360;&#x7528;&#x78C1;&#x76D8;&#x7A7A;&#x95F4;</li>
</ul>
</li>
</ul>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../day17/02.transaction.html" class="navigation navigation-prev " aria-label="Previous page: 事务"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../day17/04.user.html" class="navigation navigation-next " aria-label="Next page: 用户管理"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-splitter/splitter.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"toggle-chapters":{},"splitter":{},"emphasize":{},"highlight":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        <!-- body:end -->
    </body>
    <!-- End of book python高级 -->
</html>
